<template>
    <view class="container">
        <view class="title">咨询师1小时内解答</view>
        <view class="title2">42%211、985毕业，100%本科毕业</view>
        <view class="textbox">
            <textarea @input="questionFun" :value="question" placeholder="输入您的问题">{{ question }}</textarea>
        </view>
        <view class="title">你还可以问</view>
        <view class="targets">
            <view @tap="chooseQuestion" :data-index="index" class="df" v-for="(item, index) in static_question_data"  >
                <view class="targetitem">{{ house_name }}{{ item }}</view>
            </view>
        </view>
        <button @tap="submit" class="submit">提交问题</button>
    </view>
</template>

<script>
const app = getApp();

const functions = require('../../../utils/functions.js');

export default {
    data() {
        return {
            broker_user_id: 0,
            house_id: 0,
            house_name: '',
            question: '',
            static_question_data: ['价格是多少？', '具体位置在哪儿？', '周边有什么设施？', '交通怎么样？', '还有多少房源？', '优劣势是什么？']
        };
    },
    onLoad: function (options) {
        this.house_name=options.house_name || '';
        this.house_id=options.house_id || 0;
        this.broker_user_id=options.broker_user_id || 0
    },
	methods: {
        chooseQuestion(e) {
            var index = e.currentTarget.dataset.index;
            this.question= this.house_name +   this.static_question_data[index]
        },

        submit() {
            var that = this;
            var json = {
                broker_user_id:   this.broker_user_id,
                //关联咨询师
                house_ids:   this.house_id,
                question:   this.question //
            };

            if (!  this.question) {
                functions.toast('请输入问题内容');
                return false;
            }
            functions.checkLogin(function (ret) {
                if (ret) {
                    //继续提交
                    functions.submitAjaxData(that, '/api/xiluhouse/question/publish_question', json, function (res) {
						functions.showSuccess(res.msg,function(){
							uni.navigateBack();
						});
                    });
                } else {
                    functions.toast('请先登录');
                }
            });
        },

        questionFun(e) {
            this.question=e.detail.value
        }
    }
};
</script>
<style>
/* pages/want_ask2/want_ask2.wxss */
.container {
    padding: 30rpx 40rpx;
}
.title {
    font-size: 34rpx;
    font-weight: bold;
}
.title2 {
    font-size: 24rpx;
    color: #b8bdca;
    padding-bottom: 30rpx;
}
.textbox {
    padding: 30rpx;
    border-radius: 10rpx;
    background-color: #f6f7fa;
    margin-bottom: 40rpx;
}
.textbox textarea {
    background-color: transparent;
    font-size: 24rpx;
    width: 100%;
    height: 200rpx;
}
.targets {
    padding-top: 20rpx;
}
.targets .targetitem {
    padding: 0 10rpx;
    font-size: 24rpx;
    color: #898989;
    border-radius: 5rpx;
    background-color: #f6f7fa;
    margin-bottom: 20rpx;
    height: 45rpx;
    line-height: 45rpx;
}

.container .submit {
    width: 100%;
    height: 90rpx;
    background: #0091ff;
    box-shadow: 0rpx 4rpx 40rpx 0rpx rgba(3, 103, 179, 0.3);
    border-radius: 10rpx;
    padding: 0;
    margin: 0;
    color: #fff;
    line-height: 90rpx;
    margin-top: 60rpx;
}
</style>
